import React from 'react'
// ===================================================================== Temp
import TableModal from '#cpt/temp/TableModal'
// ===================================================================== global declare
const { $fn } = window
// ===================================================================== component
class Index extends React.Component{
	state = {
		data:[],
		pag: {},
		selectedKeys:[],
		selectedRows: [],
		forms : [
			{ label: '项目名称',		name: 'item_name',	width:300 },
		]
	}
	
	model = {}
	
	open = () => {
		const { data } = this.state
		this.modal.open()
		if(!$fn.hasArray(data)){
			this.fetch()
		}else{
			this.table.resize()
		}
	}
	close = () => $fn.clearKeys.call(this)
	// paging
	fetch = () => $fn.fetch.call(this, 'qt-item-source/select')
	
	// 表单
	cols = [
		{ title: '物价名称', 	dataIndex: 'item_name', 	width:'33%' },
		{ title: '物价代码', 	dataIndex: 'price_code', 	width:'33%'  },
		{ title: '价格', 		dataIndex: 'price', 	width:'33%'  },
	]
	
	render(){
		return TableModal.call(this,{ title:'选择物价', type:1, width:'60%', height:'60%', onOk:(keys, rows)=>{
			this.props.onRefresh?.(rows[0])
			this.modal.close()
		}})
	}
}

export default Index